<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="utf-8">
    <title>学生信息</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/AdminLTE.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pagination.css">
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
    <script src="${pageContext.request.contextPath}/js/pagination.js"></script>
    <script src="${pageContext.request.contextPath}/js/my.js"></script>
</head>
<body class="hold-transition skin-red sidebar-mini">
<!--数据展示头部-->
<div class="box-header with-border">
    <h3 class="box-title">学生信息</h3>
</div>
<!--数据展示头部-->
<!--数据展示内容区-->
<div class="box-body">
    <!-- 数据表格 -->
    <table id="dataList" class="table table-bordered table-striped table-hover dataTable text-center">
        <thead>
        <tr>
            <th class="sorting_asc">学号</th>
            <th class="sorting">姓名</th>
            <th class="sorting">出生日期</th>
            <th class="sorting">性别</th>
            <th class="sorting">手机号</th>
            <th class="sorting">邮箱号</th>
            <th class="sorting">班级</th>
            <th class="text-center">操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${pageResult}" var="student">
            <tr>
                <td> ${student.uid}</td>
                <td>${student.name}</td>
                <td>${student.birth}</td>
                <td>${student.sex}</td>
                <td>${student.tel}</td>
                <td>${student.email}</td>
                <td>${student.classid}</td>


                <td class="text-center">

                        <button type="button" class="btn bg-olive btn-xs" data-toggle="modal"
                                onclick="deleteById(${student.id})"> 删除信息
                        </button>
                        <button type="button" class="btn bg-olive btn-xs" data-toggle="modal" data-target="#borrowModal"
                                onclick="findById(${student.id},'resetFrom')"> 修改信息
                        </button>


                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

    <button type="button" class="btn bg-olive btn-xs" onclick="prePage(${pageNum},${pages})"
    >上一页</button>&nbsp;${pageNum}&nbsp;
    <button type="button" class="btn bg-olive btn-xs" onclick="nextPage(${pageNum},${pages})"
    >下一页</button>

    <!-- 数据表格 /-->
</div>
<!-- 数据展示内容区/ -->
<%--引入存放模态窗口的页面--%>
<jsp:include page="/admin/book_modal.jsp"></jsp:include>
<script>
    function prePage(index,pages) {
        if(index>1) index=index-1;
        else index=1;
        var url="/book/selectPageByIndex?index="+index;
        $.get(url,function (response) {
            console.log(response);
        });
    }
    function nextPage(index) {
        if(index>=pages) index=pages;
        else index=index+1;
        var url="/book/selectPageByIndex?index="+index;
        $.get(url,function (response) {
            console.log(response);
        });
    }
</script>
</body>
</html>
